/*
 * Copyright (c) 2016, www.zm0618.com All Rights Reserved..
 */

package com.ibetter.mr.grade.medic.collect;

import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.io.DoubleWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * Created by zhaojun on 2016/12/10.
 */
public class GradeUserCollectMapper   extends Mapper<LongWritable,Text,Text,DoubleWritable> {

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        if (value!=null){//评论0.1分
            String valStr=value.toString();
            if (StringUtils.isNotBlank(valStr)){
                String[] commentFields = valStr.split(",");
                context.write(new Text(StringUtils.join(new String[]{StringUtils.trim(commentFields[2]),StringUtils.trim(commentFields[1])},",")),new DoubleWritable(0.3));
            }
        }
    }
}
